<?php

namespace app\index\controller;
use EasyWeChat\Factory;
use think\Config;

class Server
{
    private $APIs   = ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone'];

    public function index()
    {
        $config = Config::get("wechat");

        $app = Factory::officialAccount($config);

        $response = $app->server->serve();

        // 将响应输出
        $response->send();
        exit; // Laravel 里请使用：return $response;
    }

    public function js()
    {
        $url = input("url");

        $config = Config::get("wechat");
        $app = Factory::officialAccount($config);
        $app->jssdk->setUrl($url);
        return $app->jssdk->buildConfig([],false,false, $json = true);//获取分享所需参数
    }
}